<%inherit file="/mtp.html"/>

<h1>Attachment ${c.attachment.name} to page <a href="${h.url_for('page', id=c.page.urlTitle())}">${c.page.title}</a></h1>

<div class="attachment_info">
<h2>Info</h2>
<table>
    <tr><th>Revision:</th><td>${c.attachment.revision}</td></tr>
    <tr><th>Author:</th><td>${c.attachment.author.username if c.attachment.author else 'anon'}</td></tr>
    <tr><th>Size:</th><td>${c.attachment_size} bytes</td></tr>
    <tr><th>Mime-Type:</th><td>${c.attachment.mime}</td></tr>
    <tr><th>MD5:</th><td>${c.attachment.md5}</td></tr>
</table>
</div>

<div class="attachment_preview">
    <h2>Preview</h2>
% if c.attachment.mime.startswith('image'):
    <img src="${h.url_for('page_attachment', page_id=c.page.urlTitle(), id=c.attachment.name)}"/>
% elif c.attachment.mime.startswith('text') or c.attachment.mime == 'application/xml':
    <pre>${c.attachment.textContent() | h}</pre>
% endif
</div>

<div class="attachment_history">
    <h2>History</h2>
    <ul>
    % for revision in c.revisions:
        <li>${revision.revision} 
            ${revision.author.username if revision.author else ''}
            ${h.formatdatetime(revision.created)}
            ${revision.comment if revision.comment else ''}
        </li>
    % endfor
    </ul>
</div>
